import request from "@/utils/request";
// import { requestType } from './types.ts'
interface requestType {
  deviceId: string | number
}
interface pumpType {
  pumpId: string | number
}
// interface deviceType {
//   page: number,
//   size: number,
//   [key: string]: any;
// }
// interface ResponseData {
//   data: any,
//   total?: number,
// }
interface requestResult {
  code: string;
  message: string;
  data: any;
  [key: string]: any;
};
//获取设备列表
export const getDeviceList = (data: any) => {
  return request<requestResult>({
    url: '/device/list',
    method: 'GET',
    data,
  })
}
//登录
export const login = (data: any) => {
  return request<requestResult>({
    url: '/user/login',
    method: 'POST',
    data,
  })
}
//修改用户密码
export const updatePassword = (data: any) => {
  return request<requestResult>({
    url: '/user/updatePwd',
    method: 'PUT',
    data,
  })
}
//修改泵房密码
export const updatePumpRoomPassword = (data: any) => {
  return request<requestResult>({
    url: '/device/pwd',
    method: 'PUT',
    data,
  })
}
//验证泵房控制密码
export const checkPumpRoomPassword = (data: any) => {
  return request<requestResult>({
    url: '/device/control',
    method: 'POST',
    data,
  })
}
//获取泵站运行数据
export const getDeviceData = (data: any) => {
  return request<requestResult>({
    url: '/device/pump',
    method: 'GET',
    data,
  })
}
//切换模式
export const switchMode = (data: any) => {
  return request<requestResult>({
    url: '/device/model',
    method: 'PUT',
    data,
  })
}
//启动水泵
export const startPump = (data: any) => {
  return request<requestResult>({
    url: '/device/start',
    method: 'PUT',
    data,
  })
}
//关闭水泵
export const stopPump = (data: any) => {
  return request<requestResult>({
    url: '/device/close',
    method: 'PUT',
    data,
  })
}
export const endPump = (data: any) => {
  return request<requestResult>({
    url: '/device/stop',
    method: 'PUT',
    data,
  })
}
//故障复位
export const resetPump = (data: any) => {
  return request<requestResult>({
    url: '/device/reset',
    method: 'PUT',
    data,
  })
}
//电动阀开
export const openValve = (data: any) => {
  return request<requestResult>({
    url: '/device/startValve',
    method: 'PUT',
    data,
  })
}
//电动阀关
export const closeValve = (data: any) => {
  return request<requestResult>({
    url: '/device/closeValve',
    method: 'PUT',
    data,
  })
}
//真空泵开
export const openVacuum = (data: any) => {
  return request<requestResult>({
    url: '/device/startPump',
    method: 'PUT',
    data,
  })
}
//真空泵关
export const closeVacuum = (data: any) => {
  return request<requestResult>({
    url: '/device/closePump',
    method: 'PUT',
    data,
  })
}


//上升闸门
export const openUpperGate = (data: requestType) => {
  return request<requestResult>({
    url: '/device/rise',
    method: 'PUT',
    data,
  })
}

//停止上升闸门
export const stopUpperGate = (data: requestType) => {
  return request<requestResult>({
    url: '/device/stopRise',
    method: 'PUT',
    data,
  })
}
//下降闸门
export const openLowerGate = (data: requestType) => {
  return request<requestResult>({
    url: '/device/decline',
    method: 'PUT',
    data,
  })
}

//停止下降闸门
export const stopLowerGate = (data: requestType) => {
  return request<requestResult>({
    url: '/device/stopDecline',
    method: 'PUT',
    data,
  })
}
//获取闸门数据
export const getGateData = (data: requestType) => {
  return request<requestResult>({
    url: '/device/gate',
    method: 'GET',
    data,
  })
}

//四情设备详情device/deviceData
export const getSiqingData = (data: requestType) => {
  return request<requestResult>({
    // url: '/device/deviceData',
    url: '/siqing/querySiqingDataByPumpId',
    method: 'GET',
    data,
  })
}

//泵站实时监测数据pumpId
export const getRealTimeData = (data: pumpType) => {
  return request<requestResult>({
    url: '/pumpMonitorData/queryMonitorDataByPumpId',
    method: 'GET',
    data,
  })
}
//累计数据查询pumpId
export const getAccumulateData = (data: pumpType) => {
  return request<requestResult>({
    url: '/pumpMonitorData/querySumMonitorDataByPumpId',
    method: 'GET',
    data,
  })
}
export const getRtsp = (data: any) => {
  return request<any>({
    url: '/device/createRtmpLive',
    method: 'POST',
    data,
  })
}

//获取水质监测数据
export const getWaterData = (data: any) => {
  return request<requestResult>({
    url: '/water/quality/monitoring/getWaterQualityByPumpId',
    method: 'GET',
    data,
  })
}

//云台控制
export const ptzControlStart = (data: any) => {
  return request<requestResult>({
    url: '/device/ptz/start',
    method: 'POST',
    data,
  })
}


export const ptzControlStop = (data: any) => {
  return request<requestResult>({
    url: '/device/ptz/stop',
    method: 'POST',
    data,
  })
}
//获取播放token
export const getAccessToken = (data: any) => {
  return request<requestResult>({
    url: '/device/getAccessToken',
    method: 'GET',
    data,
  })
}

//获取字典
export const getDictionary = (data: any) => {
  return request<requestResult>({
    url: '/dict/queryDictInfoByType',
    method: 'GET',
    data,
  })
}

//历史数据
export const getHistoryData = (data: any) => {
  return request({
    url: '/pumpMonitorData/queryDeviceHistoryDataPage',
    method: 'POST',
    data
  })
}
